import React from 'react';
import { observer, inject } from 'mobx-react';
import { routerShape } from 'react-router';
import { getAntd, getEcCom, getLabel } from '../../util/convert';
const { WeaReqTop, WeaRightMenu, WeaErrorPage, WeaTools } = getEcCom();
import FormContent from './FormContent';
import TopPrompt from '../topPropmpt/index';
import SecondAuthInfo from "../topPropmpt/SecondAuthInfo";
import Status from '../status/StatusAsync';
import ImgZoom from './ImgZoom';

//智能预测流程图
import SmartGuessWfMap from '../smartGuessMap/smartGuessAsync';

import ReqFreeNode from '../dialog/ReqFreeNode';
import ImportDetail from '../dialog/import-wf-detail/index';
import ImportWf from '../dialog/import-wf/index';
import EhOperator from '../dialog/eh-operator/index';
import RejectChoose from '../dialog/reject-choose/index';
import OverTimeSetting from '../dialog/overtime-setting/index';
import RequestWithdraw from '../dialog/request-withdraw/requestWithdraw';
import PrintLog from '../dialog/print-log/index';
import FreeFlowSet from '../dialog/wf-free-flowset/index';

//流程提交确认弹框
import EnsureSubmit from '../dialog/ensure-submit/index.js';

import SecondAuthDialog from "../../asyncComps/SecondAuthDialog";
import SecondAuthDetail from "../../asyncComps/SecondAuthDetailDialog";
import * as secondAuthTypes from "../../constants/secondAuthType";

import Resource from '../../asyncComps/Resource';
import Share from '../../asyncComps/Share';
import ModifyLog from '../../asyncComps/ModifyLog';
import Forward from '../../asyncComps/Forward';
import GWForward from '../../asyncComps/GWForward';
import HrmEmployeeSetting from '../../asyncComps/HrmEmployeeSetting';
import SendSms from '../../asyncComps/SendSms';
import SendEmail from '../../asyncComps/SendEmail';//新建邮件
import { Synergy } from '../../asyncComps/Portal';
import BatchSubmit from '../../asyncComps/BatchSubmit';
import ForwardBack from '../../asyncComps/ForwardBack';
import Communication from '../../asyncComps/Communication';
import SelectNextFlow from '../dialog/select-next-flow/index';
import EnableProcessAdditionAndSubtraction from '../dialog/custom-freenode-as/index';
import EnableProcessIntervention from '../dialog/custom-submit-as/index';
import InterventionDialog from '../dialog/intervention/index';
import SelectNextFlowNodeInfo from '../dialog/select-next-flow/NodeInfoDialog';
import LocationMap from '../dialog/location-map/index';
import RemindSet from '../../asyncComps/RemindSet';
import FollowTypeSelect from '../../asyncComps/FollowTypeSelect';
import ContinuationProcess from '../../components/continuationProcess/ContinuationProcess';
import OdocTemplateListCom from '../../public/wea-odoc-mouldList';//公文流程套红节点添加套红模板列表

import * as type from '../../constants/type';
import '../../style/main';
import { controlAsyncLoad } from '../../util/asyncLoad';
import * as Util from '../../util/formUtil';
import * as rightBtn from '../../util/rightBtn';
import * as OtherModule from '../../util/otherModule';
import * as _ from '../../util/public/common';
import * as AI from '../../util/public/analyzeData';
import * as GlobalUtil from "../../util/public/globalUtil";
import OdocInnerChange from '../dialog/odoc-innerChange';
import  { unbindOnMessage } from "../../util/public/invoiceUtil";

import RelatedWorkflow  from '../../asyncComps/relatedWorkflow';

@inject('globalStore', 'layoutStore', 'shareStore', 'followSelectStore')
@observer
class ReqIndex extends React.Component {
    static contextTypes = {
        router: routerShape
    }
    constructor(props) {
        super(props);
    }
    componentDidMount() {
        const { globalStore,layoutStore } = this.props;
        jQuery("body").attr("class", "bodyOverflowHidden");     //附件删除、明细删除等动作会清除掉body上的CSS，class不会清除，why?
        Util.bindResizeEvent();//解决流程图tab和正文tab高度不能自适应问题1
        Util.bindTagTypeShowEvent();//控制流程关注标签弹框是否展示
        controlAsyncLoad();
        GlobalUtil.loadCaculateResource();


        if(true){
            
            jQuery("body").click(function(e){
                if(layoutStore&&layoutStore.propFileCfg&&layoutStore.propFileCfg.openSeeIncome==1){
                    try{
                        let needHide=true;
                        // if(globalStore.variableMap.has('islsx7')&&globalStore.variableMap.get('islsx7')){
                        //     if (remark_div&&e.target.compareDocumentPosition(remark_div) === 10) {
                        //         needHide=false;
                        //     }
                        //   let wfdialog=document.getElementsByClassName('wf-signature-dialog');
                        //     if(wfdialog&&wfdialog.length>0){
                        //         needHide=false;
                        //     }

                        //     if(needHide){
                        //         setTimeout(() => {
                        //             globalStore.controlVariableMap('islsx7',false);
                        //         }, 300);
                        //     }
                            
                        // }
        
                        if(globalStore.variableMap.has('islsx6')&&globalStore.variableMap.get('islsx6')>0){
                            let remark_div=  document.getElementById('remark_div');

                            
                            if (remark_div&&e.target.compareDocumentPosition(remark_div) === 10) {
                                needHide=false;
                              }
                              let wfdialog=document.getElementsByClassName('wf-signature-dialog');
                              if(wfdialog&&wfdialog.length>0){
                                  needHide=false;
                              }

                              if(needHide){
                                let remark_needAdd=document.getElementById('needAdd');
                                if(remark_needAdd&&e.target.compareDocumentPosition(remark_needAdd) === 10){
                                    needHide=false;
                                }
                              }

    
                              if(needHide){
                                setTimeout(() => {
                                    if(globalStore.variableMap.get('islsx6')==2){
                                        // jQuery("#log_del_"+window.lsxlogid).show();
                                        jQuery("[id^='log_del_']").show();
                                    }
                                    globalStore.controlVariableMap('islsx6',0);
                                }, 300);
                            }
                        }
        
                    }catch(e){
                        if(window.console){
                            console.log(e);
                        }
                    }
                }
            });
        }

 
    }
    componentDidUpdate(preProps) {
        controlAsyncLoad();
    }
    componentWillUnmount() {
        const { globalStore } = this.props;
        const { commonParam={} } = globalStore;
        const { useInvoiceCloud } = commonParam;
        globalStore.resetStore();
        if(useInvoiceCloud == true){
            unbindOnMessage();
        }
    }
    render() {
        const { WeaShowUrl, WeaCollect, WeaDialog } = getEcCom();
        const { globalStore, layoutStore, shareStore, followSelectStore } = this.props;
        const { JSComplete, loading, tabKey, commonParam, rightMenu, dialogVisible, variableMap, promptInfo,
            promptInfos = [], secondAuthInfo, urlParams, signReplyInfo, clearReplyInfo, btnDisabled, apiBtnDisabled, innerChangeDialog, setInnerChangeDialog, continuationProcessInfo,relatedProcess=0 } = globalStore;
        const { requestid, workflowid, titlename, isshared, helpdocid, hasNewCommunication, f_weaver_belongto_userid, f_weaver_belongto_usertype } = commonParam;
        const { isFree, freeNode = {}, isImportDetail = false } = rightMenu;
        const { msginfo = [] } = shareStore;
        const { firstSharer, showAI } = urlParams;
        const { dataJson, odocInfo } = layoutStore;
        const containOdocTab = odocInfo.docFlag === true;
        const hasLoad = !_.isEmpty(commonParam) && !_.isEmpty(dataJson);
        const { WeaShare } = getEcCom();
        const sharer_new = firstSharer ? firstSharer : f_weaver_belongto_userid;
        const forceRender = variableMap.get("forceRenderReq") || 0;    //勿刪
        let dropMenuProps = {};
        dropMenuProps.showUrlDialog = () => {
         globalStore.controlVariableMap("menu_showUrl", true) 
        };
        if (hasLoad && helpdocid > 0)
            dropMenuProps.helpParams = { helpDocid: helpdocid };
        let showOdocTag = true;
        let showOdocMouldList = false;
        if (containOdocTab) {
            const { docParam, docFlag, docFieldId } = odocInfo;
            if (!!docParam) {
                const isTextInForm = docParam.isTextInForm;
                const isColumnShow = docParam.isColumnShow;
                const isTextInFormCanEdit = docParam.isTextInFormCanEdit;
                const docfiletype = docParam.docfiletype;
                const docid = docParam.docid;
                if ((isTextInForm || isColumnShow > 0) && isTextInFormCanEdit > 0 && docid > 0 && (docfiletype == '3' || docfiletype == '7' || docfiletype == '6' || docfiletype == '12' || docfiletype == '13')) {
                    showOdocTag = false;
                }
                showOdocMouldList = (docParam.isShowSelectOtherMould == true && docParam.hasUsedTemplet != '1') ? true : false;
            }
        }
        let tabDatas = [
            { title: getLabel(34130, "流程表单"), key: "form" },
            { title: getLabel(18912, "流程图"), key: "pic" },
            { title: getLabel(386192, "流程状态"), key: "status" },
        ];
        // relatedProcess==1&&tabDatas.push({title: getLabel(22105, "相关流程"), key: "relatedWorkflow"})
        if (containOdocTab && showOdocTag && !commonParam.belongTest)
            tabDatas.push({ title: getLabel(1265, "正文"), key: "odoc" });
        if (requestid > 0 && !_.isEmpty(commonParam))
            tabDatas.push({ title: getLabel(386426, "相关资源"), key: "resource" });
        if (requestid > 0 && isshared == '1' && !commonParam.belongTest)
            tabDatas.push({ title: getLabel(386153, "流程共享"), key: "share" });

        if (requestid > 0 && commonParam.isOpenCommunication == 1) {
            tabDatas.push({
                titleText: getLabel(15153, '相关交流'),
                title: (<div className="form-tab-communication">
                    <span>{getLabel(15153, '相关交流')}</span>
                    <span className={hasNewCommunication && !variableMap.has("haveClick_communication") ? "form-tab-communication-dot" : "form-tab-communication-dotHide"}></span></div>), key: 'communication'
            });
        }
        if (variableMap.has('customTabs')) {
            let customTabs = mobx.toJS(variableMap.get('customTabs'));
            tabDatas = tabDatas.concat(customTabs);
        }
        //允许拦截接口做排序、重命名
        typeof window.WfForm.overrideTabDatas === "function" && (tabDatas = window.WfForm.overrideTabDatas(tabDatas));
        let tempIndex = tabDatas.length-1;
        tabDatas&&tabDatas.map((v,index)=>{
            if(v.key =="pic"){
                tempIndex=index;    
            }
        })
        relatedProcess==1&&tabDatas.splice(tempIndex,0,{title: getLabel(22105, "相关流程"), key: "relatedWorkflow"});

        let showDropIcon = { showDropIcon: true };
        let rightMenuDisabled = false;
        if (tabKey == "odoc") {
            showDropIcon = { className: "workflowForm_odoc" }
            rightMenuDisabled = true;
        }
        let titleContent = variableMap.has("attention_titlename") ? titlename + variableMap.get("attention_titlename") : titlename;
        const wfImportParams = Util.getWfImportParams();
        
        return (
            <div className="wf-req">

                {/* 流程连续处理功能条 */}
                {
                    continuationProcessInfo.loaded && <ContinuationProcess ecId={`${this && this.props && this.props.ecId || ''}_ContinuationProcess@d7pw1v`} continuationProcessInfo={continuationProcessInfo} />
                }

                {
                    JSComplete && WeaShowUrl && <WeaShowUrl ecId={`${this && this.props && this.props.ecId || ''}_WeaShowUrl@3magwr`}
                        urlVisible={variableMap.get("menu_showUrl") || false}
                        onCancel={() => globalStore.controlVariableMap("menu_showUrl", false)}
                    />
                }
                {
                    JSComplete && WeaCollect && !commonParam.belongTest && <WeaCollect ecId={`${this && this.props && this.props.ecId || ''}_WeaCollect@jph3y1`}
                        favouritetype="2"
                        favname={Util.getPageTitle()}
                        objid={requestid}
                        visible={variableMap.get("menu_showCollect") || false}
                        onClose={() => globalStore.controlVariableMap("menu_showCollect", false)}
                    />
                }
                {/* <div className="wf-req-topprompt">
                        <SecondAuthInfo {...mobx.toJS(secondAuthInfo)} />
                    </div> */}
                <div className="wf-req-topprompt">
                    <TopPrompt ecId={`${this && this.props && this.props.ecId || ''}_TopPrompt@75z8xz`} promptInfos={promptInfos} secondAuthInfo={mobx.toJS(secondAuthInfo)} />
                </div>
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@1ok9r0`} width={165}
                    {...dropMenuProps}
                    datas={this.getRightMenu()}
                    disabled={rightMenuDisabled}
                >
                    <WeaReqTop ecId={`${this && this.props && this.props.ecId || ''}_WeaReqTop@mf7fy7`}
                        title={<div dangerouslySetInnerHTML={{ __html: titleContent }} />}
                        loading={loading}
                        icon={<i className='icon-coms-workflow' />}
                        iconBgcolor='#0079DE'
                        buttons={this.getTopButtons()}
                        tabDatas={tabDatas}
                        selectedKey={tabKey}
                        onChange={(key) => Util.switchFormTab(key)}
                        {...showDropIcon}
                        dropMenuProps={dropMenuProps}
                        dropMenuDatas={this.getRightMenu()}
                    >
                        {hasLoad && <FormContent ecId={`${this && this.props && this.props.ecId || ''}_FormContent@g9f33k`} />}
                        {
                            <div className='wf-req-picture' style={{ display: tabKey === 'pic' ? 'block' : 'none', height: '100%' }} >
                                <SmartGuessWfMap ecId={`${this && this.props && this.props.ecId || ''}_SmartGuessWfMap@a1t2z6`} commonParam={commonParam} />
                                {/* <iframe className='req-workflow-map' src='' style={{ border: 0, width: '100%' }}></iframe> */}
                            </div>
                        }
                        <div className='wf-append-iframe' style={{ display: tabKey.indexOf('custom_iframe_') > -1 ? 'block' : 'none' }}>
                            <iframe className='custom-tab-iframe' src='' style={{ border: 0, width: '100%', height: '100%' }}></iframe>
                        </div>
                        {
                            JSComplete && variableMap.has("haveClick_status") && <div className='wf-req-status' style={{ display: tabKey === 'status' ? 'block' : 'none' }}>
                                <Status ecId={`${this && this.props && this.props.ecId || ''}_Status@kxpv8k`} requestid={requestid} />
                            </div>
                        }
                        {
                            containOdocTab && <div className='wf-req-odoc' style={{ display: 'none' }}>
                                {showOdocMouldList && <OdocTemplateListCom ecId={`${this && this.props && this.props.ecId || ''}_OdocTemplateListCom@3zk6vo`} />}
                                <div className={showOdocMouldList ? 'setOdocIframeWidth iframeDiv' : 'iframeDiv'} >
                                    <iframe className='req-workflow-odoc' src='' style={{ border: 0, width: '100%', height: '100%' }}></iframe>
                                </div>
                            </div>
                        }
                        {
                            variableMap.has("haveClick_resource") && <div className='wf-req-resources' style={{ display: tabKey === 'resource' ? 'block' : 'none' }}>
                                <Resource ecId={`${this && this.props && this.props.ecId || ''}_Resource@pabu9i`} commonParam={commonParam} />
                            </div>
                        }
                        {
                            variableMap.has("haveClick_share") && <div className='wf-req-share' style={{ display: tabKey === 'share' ? 'block' : 'none' }}>
                                <Share ecId={`${this && this.props && this.props.ecId || ''}_Share@l6g5w4`} commonParam={commonParam} />
                            </div>
                        }
                      
                         {
                            variableMap.has("haveClick_communication") && tabKey === 'communication'  && <div className='wf-req-comunication'>
                                <Communication ecId={`${this && this.props && this.props.ecId || ''}_Communication@352a9d`} commonParam={commonParam} />
                            </div>
                        }
                        {
                            variableMap.has("haveClick_relatedWorkflow") && tabKey === 'relatedWorkflow' && relatedProcess==1 && <div className='wf-req-comunication' style={{ display: tabKey === 'relatedWorkflow' ? 'block' : 'none' }}>
                            <RelatedWorkflow ecId={`${this && this.props && this.props.ecId || ''}_Communication@352a9d`} commonParam={commonParam} />
                        </div>
                        }
                    </WeaReqTop>
                </WeaRightMenu>
                {
                    hasLoad && JSComplete && commonParam.existSynergy && <Synergy ecId={`${this && this.props && this.props.ecId || ''}_Synergy@of09v0`} pathname='/workflow/req' workflowid={workflowid} requestid={requestid ? requestid.toString() : "-1"} />
                }
                {
                    isFree == "1" &&
                    <ReqFreeNode ecId={`${this && this.props && this.props.ecId || ''}_ReqFreeNode@af5t0s`} freeNode={freeNode} />
                }
                {
                    isImportDetail && dialogVisible.has(type.IMPORT_WF_DETAIL_MODAL) && dialogVisible.get(type.IMPORT_WF_DETAIL_MODAL) &&
                    <ImportDetail ecId={`${this && this.props && this.props.ecId || ''}_ImportDetail@32jsho`} />
                }
                {
                    dialogVisible.has('isShowForwardDialog') &&
                    <Forward ecId={`${this && this.props && this.props.ecId || ''}_Forward@re3y0m`} forwardParams={variableMap.get('forwardParams')}
                        callBackActions={variableMap.get('callBackActions')}
                    />
                }
                 {
                    dialogVisible.has('isShowGWForwardDialog') &&
                    <GWForward ecId={`${this && this.props && this.props.ecId || ''}_GWForward@re3y0m`} forwardParams={variableMap.get('forwardParams')}
                        callBackActions={variableMap.get('callBackActions')}  isPrintShow={variableMap.get('isPrintShow')}  gwurl={variableMap.get('gwurl')} 
                    />
                }
                {
                    dialogVisible.has(type.CHOOSE_EXCEPTION_OPERATOR) &&
                    <EhOperator ecId={`${this && this.props && this.props.ecId || ''}_EhOperator@j688ak`} visible={dialogVisible.get(type.CHOOSE_EXCEPTION_OPERATOR)} />
                }
                {
                    dialogVisible.has(type.REJECT_CHOOSE) && dialogVisible.get(type.REJECT_CHOOSE) &&
                    <RejectChoose ecId={`${this && this.props && this.props.ecId || ''}_RejectChoose@ltios8`} visible={dialogVisible.get(type.REJECT_CHOOSE)} />
                }

                {/* 流程提交二次确认 */}
                {
                    dialogVisible.has(type.ENSURE_SUBMIT) && dialogVisible.get(type.ENSURE_SUBMIT) &&
                    <EnsureSubmit ecId={`${this && this.props && this.props.ecId || ''}_EnsureSubmit@xm5aok`} promptInfo={promptInfo} store={globalStore} visible={dialogVisible.get(type.ENSURE_SUBMIT)} />
                }
                {
                    dialogVisible.has(type.SELECT_NEXTFLOW) && dialogVisible.get(type.SELECT_NEXTFLOW) &&
                    <SelectNextFlow nodeAttribute={commonParam.currentNodeAttribute} ecId={`${this && this.props && this.props.ecId || ''}_SelectNextFlow@1p6jvx`} visible={dialogVisible.get(type.SELECT_NEXTFLOW)} />
                }
                {
                    dialogVisible.has(type.EnableProcessAdditionAndSubtraction) && dialogVisible.get(type.EnableProcessAdditionAndSubtraction) &&
                    <EnableProcessAdditionAndSubtraction visible={dialogVisible.get(type.EnableProcessAdditionAndSubtraction)} />
                }
                {
                    dialogVisible.has(type.EnableProcessIntervention) && dialogVisible.get(type.EnableProcessIntervention) &&
                    <EnableProcessIntervention visible={dialogVisible.get(type.EnableProcessIntervention)} />
                }
                {
                    
                    dialogVisible.has(type.Intervention_dialog) && dialogVisible.get(type.Intervention_dialog) &&
                    <InterventionDialog visible={dialogVisible.get(type.Intervention_dialog)} />
                }
                {
                    dialogVisible.has(type.SELECT_NEXTFLOW_NODEINFO) && dialogVisible.get(type.SELECT_NEXTFLOW_NODEINFO) &&
                    <SelectNextFlowNodeInfo ecId={`${this && this.props && this.props.ecId || ''}_SelectNextFlowNodeInfo@ajf8rg`} visible={dialogVisible.get(type.SELECT_NEXTFLOW_NODEINFO)} />
                }
                {
                    dialogVisible.has(type.LOCATION_MAP) && dialogVisible.get(type.LOCATION_MAP) &&
                    <LocationMap ecId={`${this && this.props && this.props.ecId || ''}_LocationMap@b75rkb`} visible={dialogVisible.get(type.LOCATION_MAP)} />
                }
                {
                    dialogVisible.has(type.OVERTIME_SETTING) && dialogVisible.get(type.OVERTIME_SETTING) &&
                    <OverTimeSetting ecId={`${this && this.props && this.props.ecId || ''}_OverTimeSetting@sv2j06`} visible={dialogVisible.get(type.OVERTIME_SETTING)} />
                }
                {
                    dialogVisible.has(type.WORKFLOW_WITHDRAW) && dialogVisible.get(type.WORKFLOW_WITHDRAW) &&
                    <RequestWithdraw ecId={`${this && this.props && this.props.ecId || ''}_RequestWithdraw@aq0kt6`} visible={dialogVisible.get(type.WORKFLOW_WITHDRAW)} />
                }
                {
                    dialogVisible.has(type.SEND_SMS) && variableMap.has(type.SEND_SMS_PARAMS) &&
                    <SendSms ecId={`${this && this.props && this.props.ecId || ''}_SendSms@29g2yo`} visible={dialogVisible.get(type.SEND_SMS)} params={variableMap.get(type.SEND_SMS_PARAMS)} closeFun={() => {
 globalStore.controlDialogVisible(type.SEND_SMS, false) 
}} />
                }
                {
                    dialogVisible.has(type.SEND_MAIL) && variableMap.has(type.SEND_MAIL_PARAMS) &&
                    //<SendSms visible={dialogVisible.get(type.SEND_SMS)} params={variableMap.get(type.SEND_SMS_PARAMS)} closeFun={() => { globalStore.controlDialogVisible(type.SEND_SMS, false) }} />

                    <SendEmail ecId={`${this && this.props && this.props.ecId || ''}_SendEmail@ll5o1u`} visible={dialogVisible.get(type.SEND_MAIL)} fwquery={variableMap.get(type.SEND_MAIL_PARAMS)} closeFun={() => {
 globalStore.controlDialogVisible(type.SEND_MAIL, false) 
}} />
                }
                {
                    dialogVisible.has(type.PRINT_LOG) && dialogVisible.get(type.PRINT_LOG) &&
                    <PrintLog ecId={`${this && this.props && this.props.ecId || ''}_PrintLog@msbdn5`} visible={dialogVisible.get(type.PRINT_LOG)} />
                }
                {
                    dialogVisible.has(type.DO_SUPERVISE) && dialogVisible.get(type.DO_SUPERVISE) &&
                    <BatchSubmit ecId={`${this && this.props && this.props.ecId || ''}_BatchSubmit@9l3t01`} visible={dialogVisible.get(type.DO_SUPERVISE)} />
                }
                {
                    dialogVisible.has(type.FORWARD_BACK) && dialogVisible.get(type.FORWARD_BACK) &&
                    <ForwardBack ecId={`${this && this.props && this.props.ecId || ''}_ForwardBack@896sbt`} visible={dialogVisible.get(type.FORWARD_BACK)} requestid={requestid} callBackActions={variableMap.get('callBackActions')} />
                }

                {
                    variableMap.has(type.HANDLE_REMIND) &&
                    <RemindSet ecId={`${this && this.props && this.props.ecId || ''}_RemindSet@rb8ode`}
                        requestId={requestid}
                        workflowId={workflowid}
                        submitType={variableMap.get(type.SUBMIT_TYPE)}
                        callBackActions={variableMap.get('callBackActions')}
                    />
                }
                {
                    dialogVisible.has(type.FORM_MODIFY_LOG) &&
                    <ModifyLog ecId={`${this && this.props && this.props.ecId || ''}_ModifyLog@xul55i`} commonParam={commonParam} visible={dialogVisible.get(type.FORM_MODIFY_LOG)} closeFun={() => {
 globalStore.controlDialogVisible(type.FORM_MODIFY_LOG, false) 
}} />
                }
                {
                    dialogVisible.has(type.HRM_EMPLOYEE_SETTING) &&
                    <HrmEmployeeSetting ecId={`${this && this.props && this.props.ecId || ''}_HrmEmployeeSetting@vno1d5`} hrmid={dialogVisible.get(type.HRM_EMPLOYEE_SETTING)} closeFun={() => {
 globalStore.controlDialogVisible(type.HRM_EMPLOYEE_SETTING, false) 
}} />
                }
                {
                    dialogVisible.has(secondAuthTypes.SECOND_AUTH_DIALOG) &&
                    <SecondAuthDialog ecId={`${this && this.props && this.props.ecId || ''}_SecondAuthDialog@vg0tpx`} visible={dialogVisible.get(secondAuthTypes.SECOND_AUTH_DIALOG)} />
                }
                {
                    dialogVisible.has(secondAuthTypes.AUTH_DETAIL_DIALOG) &&
                    <SecondAuthDetail ecId={`${this && this.props && this.props.ecId || ''}_SecondAuthDetail@8l0w9b`} visible={dialogVisible.get(secondAuthTypes.AUTH_DETAIL_DIALOG)} />
                }

                {
                    dialogVisible.has(type.FREE_FLOW_SET) &&
                    <FreeFlowSet ecId={`${this && this.props && this.props.ecId || ''}_FreeFlowSet@ftdvh8`} visible={dialogVisible.get(type.FREE_FLOW_SET)} openType='flowset' />
                }
                {
                    //流程分享
                    WeaShare && <WeaShare ecId={`${this && this.props && this.props.ecId || ''}_WeaShare@ovf4rs`} visible={dialogVisible.has(type.SHARE_WORKFLOW) && dialogVisible.get(type.SHARE_WORKFLOW)}
                        onVisibleChange={() => {
 globalStore.controlDialogVisible(type.SHARE_WORKFLOW, false); 
}} msginfo={msginfo} shareParams={{ "resourceid": requestid, "resourcetype": "152", "firstSharer": sharer_new, f_weaver_belongto_userid, f_weaver_belongto_usertype }} />
                }
                {
                    //流程导入功能
                    JSON.stringify(wfImportParams) !== "{}" && <ImportWf ecId={`${this && this.props && this.props.ecId || ''}_ImportWf@hjqdds`} loading={btnDisabled || apiBtnDisabled} menuName={wfImportParams.menuName} workflowid={wfImportParams.workflowid} formid={wfImportParams.formid} isbill={wfImportParams.isbill} userId={wfImportParams.userId} />
                }
                <ImgZoom ecId={`${this && this.props && this.props.ecId || ''}_ImgZoom@r6chp2`} />
                {
                    window.location.href.indexOf("showE8") > -1 && <div className='back_to_old_req'
                        onMouseEnter={() => globalStore.controlVariableMap("showE8", true)}
                        onMouseLeave={() => globalStore.controlVariableMap("showE8", false)}
                        onClick={() => {
 openFullWindowHaveBarForWFList(this.getE8Url()) 
}}>
                        <div style={{ display: variableMap.get("showE8") ? "block" : "none" }}>
                            <p>E8</p>
                            <p>{getLabel(19071, '模式')}</p>
                        </div>
                    </div>
                }
                {
                    showAI === "1" && <div className='back_to_old_req'
                        onMouseEnter={() => globalStore.controlVariableMap("showAI", true)}
                        onMouseLeave={() => globalStore.controlVariableMap("showAI", false)}
                        onClick={() => AI.openAIPage()}>
                        <div style={{ display: variableMap.get("showAI") ? "block" : "none" }}>
                            <p>智能</p><p>分析</p>
                        </div>
                    </div>
                }
                <iframe id="WfFormFileDownload" name="WfFormFileDownload" src="" style={{ display: 'none' }}></iframe>
                {

                    <div className="popShow" style={{ position: 'absolute', top: followSelectStore.clickPotion.y, left: followSelectStore.clickPotion.x }}>
                        <FollowTypeSelect ecId={`${this && this.props && this.props.ecId || ''}_FollowTypeSelect@bo2474`} commonParam={commonParam} curStore={followSelectStore} location={this.props.location} refresh={globalStore.getFormAttentionTag} />
                    </div>

                }
                {/* {innerChangeDialog && <OdocInnerChange visible={innerChangeDialog} doCancel={() => setInnerChangeDialog(false)} />} */}
            </div>
        )
    }
    getE8Url() {
        const { globalStore } = this.props;
        const { commonParam } = globalStore;
        const { workflowid, requestid } = commonParam;
        if (commonParam.iscreate == "1")
            return `/workflow/request/AddRequest.jsp?workflowid=${workflowid}&haveVerifyForward=true`;
        else
            return `/workflow/request/ViewRequest.jsp?requestid=${requestid}&haveVerifyForward=true`;
    }
    getTopButtons() {
        const { Button } = getAntd();
        const { globalStore, layoutStore } = this.props;
        const { btnDisabled, apiBtnDisabled, tabKey, rightMenu = {}, commonParam, promptInfo } = globalStore;
        const haveLocked = promptInfo && promptInfo.prompttype === "editlock" && promptInfo.haveLocked === true;    //被锁定
        if (tabKey === "odoc") {
            return OtherModule.getoDocTopButtons(layoutStore.odocInfo);
        }
        let btnArr = [];
        const {rightMenus = [],topBtnCount = 4} = rightMenu;
        rightMenus instanceof Array && rightMenus.map((m,index) => {
            const { type, menuName, menuIcon, menuFun, isTop, isLockShow, isTest } = m;
            if (haveLocked && !isLockShow)
                return true;
            if (isTop == "1" && btnArr.length < topBtnCount) {
                btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2oxqe7@${index}`} type="primary" title={menuName} disabled={btnDisabled || apiBtnDisabled} onClick={() => {
                    this.doRightMenuClick(m, isTest);
                }}>
                    <div className='wf-req-top-button'>{menuName}</div>
                </Button>);
            }
        });
        return btnArr;
    }
    getRightMenu() {
        const { globalStore } = this.props;
        const { JSComplete, btnDisabled, apiBtnDisabled, tabKey, rightMenu, commonParam, promptInfo, addInnerChangeBtn, setInnerChangeDialog } = globalStore;
        const haveLocked = promptInfo && promptInfo.prompttype === "editlock" && promptInfo.haveLocked === true;    //被锁定
        let btnArr = [];
        if (tabKey === "share" || tabKey === "odoc")
            return btnArr;
        const rightMenus = rightMenu && rightMenu.rightMenus || [];
        rightMenus instanceof Array && rightMenus.map((m, index) => {
            const { type, menuName, menuIcon, menuFun, isLockShow, isTest } = m;
            if (!Util.isShowRightBtn(m))
                return true;
            if (haveLocked && !isLockShow)
                return true;
            const { workflowid, formid, isbill, belongTest } = commonParam;
            if (belongTest && menuFun.indexOf("doImportWorkflow") > -1)
                return true;
            btnArr.push({
                key: `${type}_${index}`,
                icon: <i className={menuIcon} />,
                content: menuName,
                onClick: key => {
                    this.doRightMenuClick(m, isTest);
                },
                disabled: btnDisabled || apiBtnDisabled
            });
        });
        addInnerChangeBtn && btnArr.push({
            key: 'innerChange',
            icon: <i className="icon-coms-danweishezhi" />,
            content: getLabel('515700', '内部交换'),
            onClick: key => {
                // this.showInnerChangeDialog('', isTest);
                setInnerChangeDialog(true);
            },
            disabled: false
        });
        !commonParam.belongTest && btnArr.push({
            key: 'wf-collect',
            icon: <i className="icon-coms-Collection" />,
            content: getLabel("28111", "收藏"),
            onClick: key => {
                JSComplete && globalStore.controlVariableMap("menu_showCollect", true);
            },
            disabled: false
        });
        return btnArr;
    }
    doRightMenuClick(btnInfo, isTest) {
        const { commonParam } = this.props.globalStore;
        if (commonParam.belongTest && !isTest) {  //流程测试禁用的按钮
            const { Modal } = getAntd();
            Modal.warning({
                title: getLabel(131329, '信息确认'),
                content: getLabel(386161, "此操作暂不支持流程测试!"),
                okText: getLabel(83446, `确定`)
            });
            return;
        }
        //let fn = menuFun.indexOf('this') >= 0 ? `${menuFun.split('this')[0]})` : menuFun;
        //eval(key.indexOf("BTN_CUSTOMIZE") > -1 ? fn : `rightBtn.${fn}`);
        GlobalUtil.executeRightBtnClick(btnInfo, rightBtn);
    }
    formDoKeyDown(e) {
        const keyCode = Util.convertKeyCode(e);
        if (keyCode === 13) {     //解决浏览按钮等enter键导致form提交
            e.preventDefault();
            return;
        }
    }
}

export default WeaTools.tryCatch(React,
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@6ctqth`} msg={props.error ? props.error : getLabel(385218, '对不起，该页面异常，请联系管理员！')} />,
    { error: "" }
)(ReqIndex);
